#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <algorithm>  


using namespace std;


vector<int> compute_two_sum(const vector<int>& nums, int num){
	int i =0 ,j = nums.size() -1;
	while( i<  j){
		if(nums[i] + nums[j] == num){
			printf("[%d %d]", nums[i],nums[j]);
			--j;
			++i; 
		}else if(nums[i] + nums[j] > num){
			--j;
		}else if(nums[i] + nums[j] < num){
			++i;
		}
	}
}


main()
{
	int num,sum;
	vector<int> rec;
	
	printf("Please enter a set of Numbers separated by spaces:\n");
	while (cin.peek() != '\n' )
	{	
		cin >> num;
		rec.push_back(num) ;
	}
	sort(rec.begin(),rec.end());
	for(vector<int>::iterator it = rec.begin() ; it< rec.end(); it++){
		
		cout<< *it << " ";
	}
	cout<<endl;
	cin.clear();
	printf("Please enter the sum of the two numbers:\n");
	cin>> sum;
	
	compute_two_sum(rec, sum);
}

